package com.ghsc.ghxc.jsb.ui.message.fragment

import androidx.lifecycle.MutableLiveData
import com.cn.appcore.base.BaseViewModel
import com.cn.appcore.ext.executeResponse
import com.cn.appcore.http.bean.BaseResponse
import com.ghsc.ghxc.jsb.api.ApiMarket
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.message.fragment
 * 类名：NewRobRedFragmentViewModel
 * 创建时间：2024/6/4 14:47
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class NewRobRedFragmentViewModel  : BaseViewModel() {
    /**
     *  抢红包
     */
    var onGetPacketSubmitData = MutableLiveData<BaseResponse<Any>>()
    fun onGetPacketSubmitMethod(paras:String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onGetPacketSubmitData(paras) }
            executeResponse(
                response,
                { onGetPacketSubmitData.value = response },
                { againLoginMsg.value = response.msg }
            ) { getRewardErrorData.value = response }
        }
    }
}